from random import randint
import openpyxl
from openpyxl import load_workbook
import get_rand_data


def __init__():
    excel_path = 'FL_PROPERTY.xlsx'

    workbook = load_workbook(excel_path)
    sheet = workbook['Sheet1']
    # cell = sheet.cell(row=1, column=1).value

    column_name_dict = dict()
    column_count = 1
    zimu = '1'
    
    while sheet.cell(row=1, column=column_count).value is not None :
        column_count += 1
    # print(column_count)

    for i in range(1, column_count):
        column_name_dict[zimu] = sheet.cell(row = 1, column = i).value
        zimu = str(int(zimu) + 1)

    # print(column_name_dict)
    category_list = get_category_dict()
    print(get_rand_data.get_rand_row(category_list))

def get_category_dict():

    category_path = '资产国标分类.xlsx'
    category_list = list()
    category_dic = dict()
    category_dic['资产编号'] = None
    category_dic['资产名称'] = None
    category_dic['国标大类'] = None

    workbook_cat = load_workbook(category_path)
    sheet_cat = workbook_cat['Sheet0']

    row_num = 2
    while sheet_cat.cell(row=row_num, column=1).value is not None :
        
        category_dic['资产编号'] = sheet_cat.cell(row=row_num, column=1).value
        category_dic['资产名称'] = sheet_cat.cell(row=row_num, column=2).value
        category_dic['国标大类'] = sheet_cat.cell(row=row_num, column=3).value
        category_list.append(category_dic)
        row_num += 1
        category_dic = dict()
    
    return category_list



__init__()



